package com.buaa.pm.controller;

import com.buaa.pm.entity.Paragraph;
import com.buaa.pm.feign.ParagraphClient;
import com.buaa.pm.model.ResultModel;
import com.buaa.pm.service.ParagraphService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/paragraph")
public class ParagraphController {

    @Autowired
    private ParagraphService paragraphService;


    @GetMapping("/list-by-project")
    public ResultModel<List<Paragraph>> listByProject(@RequestParam String projectId) {
        return ResultModel.success(paragraphService.listParagraphByProject(projectId));
    }

    @GetMapping("/list-by-paper")
    public ResultModel<List<Paragraph>> listByPaper(@RequestParam String paperId) {
        return ResultModel.success(paragraphService.listParagraphByPaper(paperId));
    }

    @PostMapping("/update-available")
    public ResultModel<Boolean> updateAvailable(@RequestParam String paragraphId, @RequestParam boolean available){
        return ResultModel.success(paragraphService.updateParagraphAvailable(paragraphId, available));
    }

}
